import Vue from 'vue';
import Vuex from 'vuex';
import * as types from './mutations-type'

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        isPhone: false, //判断操作系统
        tabStyle: '', //tab的动态样式
        routeName: ''
    },
    actions: {},
    mutations: {
        [types.IS_PHONE](state, status) {
            state.isPhone = status
        },
        /**
         * 设置tab动态样式
         * @param state
         * @param style string
         *
         */
        [types.SET_TAB_STYLE](state, style) {
            state.tabStyle = style
            console.log(style)
        },
        /**
         * tab路由
         * @param state
         * @param routeName string
         */
        [types.SET_TAB_ROUTE](state, routeName) {
            state.routeName = routeName
            window.localStorage.setItem("routeName", routeName)
        }
    },
    getters: {
        routeName(state) {
            if (!state.routeName && window.localStorage) {
                state.routeName = window.localStorage.getItem("routeName");
            }
            return state.routeName ? state.routeName : '/'
        }
        // sid(state) {
        //     if (!state.sid && window.localStorage) state.sid = window.localStorage.getItem("sid");
        //     return state.sid ? state.sid : ''
        // },
    },

    modules: {}
});

